package 外观模式.文件操作;

import java.io.*;

/**
 * 将加密后内容写到文件中
 */
public class FileWriter {
    public void write(String encryptText,String fileNameDes){
        System.out.println("加密后进行保存");
        File des = new File(fileNameDes);
        Writer writer=null;
        try {
            writer = new OutputStreamWriter(new FileOutputStream(des));
            writer.write(encryptText);//写入文件
            writer.flush();
            System.out.println("加密并保存成功");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if (writer!=null) {
                    writer.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
